import QtQuick 1.1

Image {
    id: root
    opacity: 0
    state: "ESCONDER"

    property bool visibilidade: false

    Component.onCompleted: {
        if (root.visibilidade)
            root.mostrar();
        else
            root.esconder();
    }

    onVisibilidadeChanged: {
        if (root.status == Component.Ready) {
            if (root.visibilidade)
                root.mostrar();
            else
                root.esconder();
        }
    }

    function mostrar() {
        root.state = "ABRIR";
    }

    function esconder() {
        root.state = "ESCONDER";
    }

    states: [
        State {
            name: "ABRIR"
        },
        State {
            name: "ESCONDER"
        }
    ]

    transitions: [
        Transition {
            from: "ESCONDER"; to: "ABRIR"
            SequentialAnimation {
                SmoothedAnimation {
                    target: root; property: "opacity"; from: 0; to: 1; velocity: 1;
                }
                PauseAnimation { duration: 300 }
                SmoothedAnimation {
                    target: root; property: "opacity"; to: 0.5; velocity: 1;
                }
            }
        },
        Transition {
            from: "ABRIR"; to: "ESCONDER"
            SequentialAnimation {
                NumberAnimation {
                    target: root; property: "opacity"; to: 0; duration: 200;
                }
            }
        }
    ]
}
